<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>修改分类</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
		<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
		<script src="__PUBLIC__/static/layui/layui.js"></script>
	</head>

	<body>
		<form id="my_form" class="layui-form update_form" action="" method="post">
			<div class="layui-form-item">
				<label class="layui-form-label">分类名</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="name" lay-verify="required" value="{$data.name}" placeholder="请输入分类名" autocomplete="off" class="layui-input">
						<input type="hidden" name="id"  value="{$data.id}"  autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">排序</label>
				<div class="layui-input-block update_shurk">
					<input type="text" name="sort" lay-verify="required" value="{$data.sort}" placeholder="请输入排序" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item update_btnbox" style="text-align: center;margin-left:unset">
				<div class="layui-input-block" style="max-width: unset;float: unset;">
					<button  id='change_but' class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</body>
</html>
<script>
    //提交表单
	layui.use('form', function(){
	  var form = layui.form;
		  	//监听提交
			form.on('submit(demo1)', function(data){
				$('#change_but').addClass("layui-btn-disabled");
				$.ajax({
	             	type:"post",
	                url:"{:url('shop/types_edit')}",
	                data: $('#my_form').serialize(),//表单数据
	                success:function(data){
	                    if(data.code==200){
	                    	layer.msg(data.msg, {
							  icon: 1,
							  time: 1500 //2秒关闭（如果不配置，默认是3秒）
							}, function(){
								window.parent.location.reload();
								var index = parent.parent.layer.getFrameIndex(window.name); //获取窗口索引  
						       	parent.layer.close(index); 
							});
	                    }
	                }
        		});
			return false;
		});
	});
</script>
